package foodhelper.mtech.com;

import android.os.Bundle;
import android.app.Activity;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.util.Log;
import android.view.Menu;
import android.widget.TextView;

public class BmiShow extends Activity {

	private TextView m_BMI;
	private float extras;
	private TextView m_infos;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.bmi_show);
		extras = getIntent().getFloatExtra(BmiCaculator.BMI_DATA, (float) 0);
		Log.d("BMI","" + extras);
		m_BMI = (TextView) findViewById(R.id.bmiTW);
		m_infos = (TextView) findViewById(R.id.bmiInfos);
		m_BMI.setText(""+ extras);
		Typeface tf = Typeface.createFromAsset(getAssets(), "DroidSerif-Bold.ttf");
		
		m_BMI.setTypeface(tf);
		
		
	}
	
	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
			new Thread(new Runnable() {
			
			@Override
			public void run() {
				// TODO Auto-generated method stub
				Resources res = getResources();
				String[] bmi_levels = res.getStringArray(R.array.bmi_level);
				if(extras<15){
					m_infos.setText(R.string.ibm_coment_1);
					m_BMI.setText(bmi_levels[0]);
					}
				else if(15 <= extras && extras <16){
					m_BMI.setText(bmi_levels[1]);
					m_infos.setText(R.string.ibm_coment_1);}
				else if(16 <= extras && extras <18.5)
					m_BMI.setText(bmi_levels[3]);
				else if(18.5 <= extras && extras <25){
					m_infos.setText(R.string.bmi_comment_3);
					m_BMI.setText(bmi_levels[4]);}
				else if(25 <= extras && extras <30)
					m_BMI.setText(bmi_levels[5]);
				else if(30 <= extras && extras <35)
					m_BMI.setText(bmi_levels[6]);
				else if(35 <= extras && extras <40)
					m_BMI.setText(bmi_levels[7]);				
			}
		});
		
		
		
		super.onResume();
	}
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.bmi_show, menu);
		return true;
	}

}
